<template>
	<view>
    <image class="bg" src="/static/images/jifen.png" mode="" />
		<!-- <view class="swiper square">
			<swiper indicator-dots="true" autoplay="true" circular="1"
			 interval="5000" duration="500" indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff" style="height: 360rpx;">
				<swiper-item style="height: 360rpx;">
					<view class='slide-navigator acea-row row-between-wrapper'>
						<image style="width: 750rpx; height:360rpx;" src="../../../static/images/jf_banner1.jpg" class="slide-image aa"></image>
					</view>
				</swiper-item>
				<swiper-item style="height: 360rpx;">
					<view class='slide-navigator acea-row row-between-wrapper'>
						<image style="width: 750rpx; height:360rpx;" src="../../../static/images/jifen_banner2.jpg" class="slide-image aa"></image>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<promotionGood :benefit="benefit"></promotionGood> -->
    <!-- <category :categoryList="categoryList" :subCategoryList="subCategoryList" @categoryMainClick="categoryMainClick" @categorySubClick="categorySubClick" /> -->
	</view>
</template>

<script>
  import category from '@/components/qiyue-category/qiyue-category.vue'
	import Vtabs from '@/components/v-tabs/v-tabs.vue'
	import { getCategory, getProduct2 } from '@/api/api.js'
	import promotionGood from '@/components/promotionGood/index2.vue'
	export default {
		data() {
			return {
				hover2: 'hover',
				hover5: '',
				hover10: '',
				select_type: 2,
				current: 0,
				tabs: [
        ],
				category_list: [],
				tab_map: {},
				select_cate_id: 0,
        benefit: [],
        categoryList:[
          {
            name:'礼盒礼包',
            list: [
              {name: '良品铺子包邮'}
            ]
          },
          {
            name:'礼盒礼包',
            list: [
              {name: '良品铺子包邮'}
            ]
          },
          {
            name:'礼盒礼包',
            list: [
              {name: '良品铺子包邮'}
            ]
          },
          {
            name:'礼盒礼包',
            list: [
              {name: '良品铺子包邮'}
            ]
          },
          {
            name:'礼盒礼包',
            list: [
              {name: '良品铺子包邮'}
            ]
          },
          {
            name:'礼盒礼包',
            list: [
              {name: '良品铺子包邮'}
            ]
          },
          {
            name:'礼盒礼包',
            list: [
              {name: '良品铺子包邮'}
            ]
          },
          {
            name:'礼盒礼包',
            list: [
              {name: '良品铺子包邮'}
            ]
          }
          ],
        subCategoryList:[]
			}
    },
		created() {
			// getCategory().then(res => {
			// 	console.log(res);
			// 	let data = res.data
			// 	this.category_list = data
			// 	let arr = []
			// 	let tab_map = {}
			// 	for(let i =0;i<data.length;i++){
			// 		arr[i] = data[i].cate_name
			// 		tab_map[data[i].cate_name] = data[i].id
			// 	}
			// 	console.log(tab_map);
			// 	arr.unshift('全部')
			// 	this.tabs = arr
			// 	this.tab_map = tab_map
			// 	this.getProducts()
			// })
		},
		onLoad() {
			let cate_id = uni.getStorageSync('select_cate_id') || 0
			uni.setStorageSync('select_cate_id', 0)
			let that = this
			// setTimeout(function(){
			// 	that.current = cate_id
			// 	that.changeTab(cate_id)
			// },1000)
		},
		onShow() {
			let cate_id = uni.getStorageSync('select_cate_id') || 0
			uni.setStorageSync('select_cate_id', 0)
			let that = this
			// setTimeout(function(){
			// 	that.current = cate_id
			// 	that.changeTab(cate_id)
			// },1000)
		},
		methods: {
			changeType(type){
				// if(type == 2){
				// 	this.hover2 = 'hover'
				// 	this.hover5 = ''
				// 	this.hover10 = ''
				// }else if(type == 5){
				// 	this.hover2 = ''
				// 	this.hover5 = 'hover'
				// 	this.hover10 = ''
				// }else if(type == 10){
				// 	this.hover2 = ''
				// 	this.hover5 = ''
				// 	this.hover10 = 'hover'
				// }
				// this.select_type = type
				// this.getProducts()
			},
			changeTab: function(category){
				console.log(category);
				let tabs = this.tabs
				let cate_name = tabs[category]
				console.log(cate_name);
				let tab_map = this.tab_map
				console.log(tab_map);
				let id = tab_map[cate_name]
				id = id == id ? id : 0
				this.select_cate_id = id
				this.getProducts()
			},
			// getProducts: function(){
			// 	let params = {
			// 	}
			// 	getProduct2(params).then(res => {
			// 		console.log(res);
			// 		this.benefit = res.data
			// 	})
      // },
      categoryMainClick(category){
        this.subCategoryList = category.subCategoryList;
      },
      categorySubClick(category){
        console.log(category);
      }
		},
		components: {
			Vtabs,
      promotionGood,
      category
    },
    mounted() {
      this.subCategoryList = this.categoryList[0].list
                // for(var i=0;i<20;i++){
                //     var subList = [];
                //     for(var j=0;j<30;j++){
                //         subList.push({"name":"分类"+i+":商品"+j,"logo":"http://placehold.it/50x50"})
                //     }
                //     this.categoryList.push({"name":"分类"+i,"subCategoryList":subList})
                // }
                // this.subCategoryList = this.categoryList[0].subCategoryList;
            }
	}
</script>

<style>
.bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
	/* .nav_list{
		padding-top: 20rpx;
	}
	.nav_list_item{
		width: 33.3%;
		float: left;
		text-align: center;
	}
	.nav_list_item image{
		width: 220rpx;
		height: 160rpx;
		border-radius: 20rpx 100rpx 100rpx;
	}
	.nav_list_item image.hover{
		border: 10rpx solid #C68937;
	} */
</style>
